package elitech.vietnam.myfashion.extend;

import java.util.List;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import elitech.vietnam.myfashion.MainActivity;
import elitech.vietnam.myfashion.entites.OrderDetail;
import elitech.vietnam.myfashion.view.OrderDetailView;
import elitech.vietnam.myfashion.view.OrderDetailView.OrderDetailViewEvent;

public class OrderDetailArrayAdapter extends ArrayAdapter<OrderDetail> {
	private MainActivity mContext;
	private boolean mIsCart = false;
	public OrderDetailArrayAdapter(MainActivity context, int resource,
			List<OrderDetail> objects, boolean isCart) {
		super(context, resource, objects);
		this.mContext = context;
		this.mIsCart = isCart;
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final OrderDetail detail = getItem(position);
		OrderDetailView view = new OrderDetailView(mContext, detail);
		if(mIsCart){
			view.mBtnDelete.setVisibility(View.VISIBLE);
			view.setOnCancelEvent(new OrderDetailViewEvent() {
				
				@Override
				public void onCancel() {
					remove(detail);
					onCancel();
				}
			});
		}
		return view;
	}
	
	public void onCancel(){}
	
}
